<script setup>
//24小时热榜获取数据
import {gethotgoods} from '@/apis/detail.js'
import { computed, onMounted, ref } from 'vue';
import { useRoute } from 'vue-router';
const route = useRoute()
const hotlist = ref([])
//poprs参数
const props =  defineProps({
  type:Number
})
const titil = computed(()=>{
  if(props.type===1)return '24小时热榜'
  if(props.type===2)return '周热榜'
  if(props.type===3)return '总热榜'
})

const gethotdata=(async()=>{
 const res = await  gethotgoods({
  id:route.params.id,
  type:props.type,
 })
 hotlist.value = res.result
})
onMounted(()=>{
  gethotdata()
})
</script>


<template>
  <div class="goods-hot">
    <h3>{{titil}}</h3>
    <!-- 商品区块 -->
    <RouterLink :to="`/detail/${item.id}`" class="goods-item" v-for="item in hotlist" :key="item.id">
      <img :src="item.picture" />
      <p class="name ellipsis">{{ item.name }}</p>
      <p class="desc ellipsis">{{ item.desc }}</p>
      <p class="price">&yen;{{ item.price }}</p>
    </RouterLink>
  </div>
</template>


<style scoped lang="scss">
.goods-hot {
  h3 {
    height: 70px;
    background: $helpColor;
    color: #fff;
    font-size: 18px;
    line-height: 70px;
    padding-left: 25px;
    margin-bottom: 10px;
    font-weight: normal;
  }

  .goods-item {
    display: block;
    padding: 20px 30px;
    text-align: center;
    background: #fff;

    img {
      width: 160px;
      height: 160px;
    }

    p {
      padding-top: 10px;
    }

    .name {
      font-size: 16px;
    }

    .desc {
      color: #999;
      height: 29px;
    }

    .price {
      color: $priceColor;
      font-size: 20px;
    }
  }
}
</style>